//
//  WBBaseViewController.swift
//  weibo
//
//  Created by Felix on 16/11/6.
//  Copyright © 2016年 Felix. All rights reserved.
//

import UIKit

class WBBaseViewController: UITableViewController {

    ///1.判断是否授权登陆
    let isLogin = WBUserAccount.isLoggin()
    
    
    var visitorView:WBVisitorView? = nil
    
    
    override func viewDidLoad() {
        ///1.如果登陆了则调用视图创建方法、如没有登陆则调用访客视图创建方法
        isLogin ? super.viewDidLoad():setUpVisterView()
    }
    
    /// 创建访客视图
    private func setUpVisterView(){
        visitorView = WBVisitorView.visitor()
        view = visitorView;
        let bat = UIButton()
        
        
        visitorView?.loginButton .addTarget(self, action: #selector(loginButtonClick), for: UIControlEvents.touchUpInside)
        
        visitorView?.registerButton.addTarget(self, action: #selector(rigisterButtonClick), for: UIControlEvents.touchUpInside)
    }
    
  
    @objc private func loginButtonClick(sender:UIButton) -> Void {
        let oauth = UIStoryboard.init(name: "WBOAuth", bundle: nil)
        present(oauth.instantiateInitialViewController()!, animated: true, completion: nil)
    }

    @objc private func rigisterButtonClick(sender:UIButton) -> Void {
        AdaLog(message: "注册按钮点击")
    }
    
    
}
